#include <stdio.h>
int main()
{
int count=0;
int count2=0;
int i,j,k,p;
int e,r;
int n,m;
scanf("%d",&n);
int a[n];
scanf("%d",&m);
int b[m];
for(i=0;i<n;i++)
{scanf("%d",&a[i]);

}
for(j=0;j<m;j++)
   {scanf("%d",&b[j]);

   }
   for(k=0;k<n;k++)
   {count=0;
       for(p=0;p<m;p++)
   {if(a[k]!=b[p])
   {count++;
   }

   }

   if(count%m==0)
    printf("%d ",a[k]);
    }
    for(e=0;e<m;e++)
   {count2=0;
       for(r=0;r<n;r++)
   {if(b[e]!=a[r])
   {count2++;}

   }

   if(count2%n==0)
    printf("%d ",b[e]);
    }
    return 0;
}
